package com.hp.bon.sgw.wh.utils;

import org.junit.Test;

import junit.framework.TestCase;

/**
 * @author suxinj
 * 
 */
public class SignatureTest extends TestCase {

	/** 私钥   pkcs8格式*/
	private String PRI_KEY = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK7pzUtjPd0jPjh1q9U1kUXCZU6zaul9lxuM/ExN4lVpcr7dMWXcPpnaBm4OOzIQ9M23J3Yu74Ie2G7hyJKe8aNS/6UusWzzKuJhc6GdvKctFCVTXm5tD/KmovscQRI5nvUpUcT1FvAM4qw/u4DybokcwNbVhjUJOKl6ZXc/vM41AgMBAAECgYBQkRrhza2SLYicYv8qLwliM3+Md7IYKKQwqYkQ8JL/OpoC9kmpnIAtR7LMgLudfRf1pZaEpmvl6KVStac4egPcrvUjYuMJpFxwnYnTUSecb7P7PGUpijKLkHTDlYi6K3AkUYzxUgnhV+uFxUncm1++Mfy6mkrw2YRKrYcwLOrhQQJBANp7wO/DCyKUxiSStA0/gOeNvKm4Ssj1Kdtb6tShuAU3uM70SwWzg6UBEL1wvZA3Fu1A+yGsyE8wTGS3cDZGN4UCQQDM8sMpzX+yU8074fa9jgDwGQLipr3sVy8txFqOxV9xuRDeJBcNj2iOrjoWPtcu/deDM8zjEGCAoI1xHgxt/YLxAkB0yMeloVUXY/zR2dUCa9pka1/YPJlE978q8OQCSntJ1rIjdXOQlZcdoQcoq9W3+6p2oVBbfLcJlSCQiXkimb/dAkBk0xUCDq/AmguAZzTMofyCIbvSpvcOOwHhwRRP4neG6eWLczPIHwHwF3RKF1YjLwwD5srn9dmTzehnesHgpnPxAkEAu87hqBCDVA/btALU3xwh8evMDfgH38aSW9/zmcU+SWwvDYv8aBg654xlsE4mJX9gjN6bLG0MRJdX4wlfqEbfyA==";
	
	/**  公钥 */
	private String PUB_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCu6c1LYz3dIz44davVNZFFwmVOs2rpfZcbjPxMTeJVaXK+3TFl3D6Z2gZuDjsyEPTNtyd2Lu+CHthu4ciSnvGjUv+lLrFs8yriYXOhnbynLRQlU15ubQ/ypqL7HEESOZ71KVHE9RbwDOKsP7uA8m6JHMDW1YY1CTipemV3P7zONQIDAQAB";

	
	/** 明文 */
	private final static String TEST_TEXT = "18971621605190243467051000FAILED9999插入serv_unblock_t表出错ERROR[ORA-01843: not a valid month\n";

	/** 加签方式 */
	private final static String ALGORITHM = "SHA1withRSA";
	
	/**字符编码*/
	private final static String CHARSET = "UTF-8";
	
	
	/**
	 * 测试加密及验签
	 */
	@Test
	public void testRSA() {
		
		//模拟支付宝利用支付宝私钥进行加签
		String signText = SignUtilsImpl.sign(TEST_TEXT, PRI_KEY, ALGORITHM, CHARSET);
		
		System.out.println(signText);
		
		//商户用支付宝的公钥进行验签
		System.out.println((SignUtilsImpl.verify(TEST_TEXT, signText, PUB_KEY, ALGORITHM, CHARSET)));
	}
}
